/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.vale;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.vale.dao.UserDAO;
import org.vale.entity.User;
import org.vale.services.LoggedUser;

/**
 *
 * @author Gabriel Bran gbran.u@gmail.com
 */
@Named
@SessionScoped()
public class SessionBean implements java.io.Serializable {

    @EJB
    private UserDAO userDAO;
    private User currentUser;
    @Inject
    @LoggedUser
    private String username;

    @PostConstruct
    public void initialize() {
        if (username != null) {
            currentUser = userDAO.find(username);
        }
    }

    public User getCurrentUser() {
        return currentUser;
    }

    public void setCurrentUser(User currentUser) {
        this.currentUser = currentUser;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

}
